package utils.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.lanou.horo.myapplication.dbdao.FristTopDbEntity;

import java.util.List;

import fragment.classicfragments.ClassifoimgViewpageFragment;

/**
 * Created by dllo on 15/11/30.
 */
public class RecomendTopDBViewPagerAdpter extends FragmentPagerAdapter {
    private List<FristTopDbEntity> image;

    public void   addImages(List<FristTopDbEntity > image){
        this.image = image;
        notifyDataSetChanged();
    }
    public RecomendTopDBViewPagerAdpter(FragmentManager fm) {
        super(fm);
    }


    @Override
    public Fragment getItem(int position) {
        FristTopDbEntity images =
                image.get(position % image.size());
        String imgUrl = images.getPic();
        return  ClassifoimgViewpageFragment.getInstance(imgUrl);
    }

    @Override
    public int getCount() {
        return image != null && image.size() > 0 ?  Integer.MAX_VALUE : 0;
    }

}
